<% title("Churches") %>

<div class="grid_12">
  <div class="bottom-spacing">
    <div class="float-right">
      <%= link_to 'New Church', new_church_path, :class => 'cta cta-yellow' %>
    </div>
      <%= form_tag churches_path, :method => 'get', :id => "churches_search" do %>
      <%= hidden_field_tag :direction, params[:direction] %>
      <%= hidden_field_tag :sort, params[:sort] %>
      <%= hidden_field_tag :recent, params[:recent] %>
      <p>
        Search:
        <%= text_field_tag :search, params[:search], :class => 'input-short' %>
        <%= submit_tag "Search", :name => nil, :class => "submit-green" %>
      </p>
    <% end %>
  </div>
  <div class="module">
    <h2><span>Churches</span></h2>
    <div class="module-table-body">
      <table id="churchTable" class="tablesorter">
        <thead>
          <tr>
            <%= sortable "name" %>
            <%= sortable "address" %>
            <%= sortable "city" %>
            <%= sortable "state" %>
            <%= sortable "zip_code" %>
            <%= sortable "phone" %>
            <%= sortable "url" %>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% @churches.each do |church| %>
          <tr class='<%= cycle("even", "odd") %>'>
            <td><%= link_to church.name, church %></td>
            <td><%= church.address %></td>
            <td><%= church.city %></td>
            <td><%= church.state %></td>
            <td><%= church.zip_code %></td>
            <td><%= church.phone %></td>
            <td><%= link_to church.url, church.url if church.url %></td>
            <td nowrap="nowrap"> <%= link_to image_tag("pencil.gif"), edit_church_path(church) %>
            <%= link_to image_tag("bin.gif"), church, confirm: 'Are you sure you want to delete this church?', method: :delete %> </td>
          </tr>
          <% end %>
        </tbody>
      </table>
      <div class="pager" id="pager">
        <span style="float:left; margin-top: 3px; padding-right: 10px;">Filters:</span>
        <%= all_filter %>
        <%= recent_filter %>
        <div style="clear: both"></div>
      </div>
    </div>
  </div>
  <%= paginate @churches %>
</div>